package l.l.w.leetcode._334_IncreasingTripletSubsequence;

/**
 * Created by llw on 2018/5/29/0029.
 */
public class _334_IncreasingTripletSubsequence {
    public boolean increasingTriplet(int[] nums) {
        if(nums == null || nums.length < 3) return false;
        int min0 = Integer.MAX_VALUE, min1 = Integer.MAX_VALUE;
        for(int i = 0; i < nums.length; ++i){
            if(nums[i] <= min0){
                min0 = nums[i];
            }
            if(nums[i] <= min1){
                if(nums[i] > min0){
                    min1 = nums[i];
                }
            }else{
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] nums = {5,4,3,2,1};
        boolean result = new _334_IncreasingTripletSubsequence().increasingTriplet(nums);
        System.out.println(result);
    }
}
